version: '3.8'
services:
  etcd1:
    image: quay.io/coreos/etcd:v3.5.0
    container_name: etcd1
    command: >
      etcd --name etcd1
           --advertise-client-urls http://etcd1:2379
           --listen-client-urls http://0.0.0.0:2379
           --initial-advertise-peer-urls http://etcd1:2380
           --listen-peer-urls http://0.0.0.0:2380
           --initial-cluster-token etcd-cluster
           --initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
           --initial-cluster-state new
    ports:
      - "2379:2379"
      - "2380:2380"
    volumes:
      - etcd1-data:/etcd-data

  etcd2:
    image: quay.io/coreos/etcd:v3.5.0
    container_name: etcd2
    command: >
      etcd --name etcd2
           --advertise-client-urls http://etcd2:2379
           --listen-client-urls http://0.0.0.0:2379
           --initial-advertise-peer-urls http://etcd2:2380
           --listen-peer-urls http://0.0.0.0:2380
           --initial-cluster-token etcd-cluster
           --initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
           --initial-cluster-state new
    ports:
      - "22379:2379"
      - "22380:2380"
    volumes:
      - etcd2-data:/etcd-data

  etcd3:
    image: quay.io/coreos/etcd:v3.5.0
    container_name: etcd3
    command: >
      etcd --name etcd3
           --advertise-client-urls http://etcd3:2379
           --listen-client-urls http://0.0.0.0:2379
           --initial-advertise-peer-urls http://etcd3:2380
           --listen-peer-urls http://0.0.0.0:2380
           --initial-cluster-token etcd-cluster
           --initial-cluster etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380
           --initial-cluster-state new
    ports:
      - "32379:2379"
      - "32380:2380"
    volumes:
      - etcd3-data:/etcd-data

volumes:
  etcd1-data:
  etcd2-data:
  etcd3-data:
